﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Evaluation3;
using Evaluation3.services;

public partial class uicontrol_hoidongNewl : System.Web.UI.UserControl
{
    cucilServices objCucil = new cucilServices();

    #region Page_Load()
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            objCucil.MaHoiDong = int.Parse(Session["HDCode"].ToString());
            
            ResetField();

            LoadHD();
        }
        catch (Exception ex)
        {
            Response.Redirect("adminRender.aspx?mod=hoidong_Info");
        }
    }
    #endregion

    #region LoadHD()
    public void LoadHD()
    {
        DataSet ds = objCucil.HD_SearchbyHDCode();
        txtTenHD.Text = ds.Tables[0].Rows[0]["TenHoiDong"].ToString();     
        txtNgayThanhLap.Text = ((DateTime)ds.Tables[0].Rows[0]["NgayThanhLap"]).ToShortDateString();
        txtQuyetDinh.Text = ds.Tables[0].Rows[0]["QuyetDinh"].ToString();
        txtNguoiKy.Text = ds.Tables[0].Rows[0]["NguoiKy"].ToString();
    }
    #endregion

    #region ResetField()
    public void ResetField()
    {
        txtTenHD.Text = "";
        this.txtNgayThanhLap.Text = DateTime.Now.ToShortDateString();
        txtQuyetDinh.Text = "";
        txtNguoiKy.Text = "";

        lblNotify.Text = "";
    }
    #endregion

    #region btnUpdate_Click()
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            objCucil.TenHoiDong = txtTenHD.Text.Trim();
            objCucil.MaDoanhNghiep = int.Parse(Session["CompanyID"].ToString());
            objCucil.NgayThanhLap = Convert.ToDateTime(txtNgayThanhLap.Text);
            objCucil.QuyetDinh = txtQuyetDinh.Text.Trim();
            objCucil.NguoiKy = txtNguoiKy.Text.Trim();

            objCucil.HD_CapNhat();

            lblNotify.Text = "Đã cập nhật thông tin Hội Đồng thành công.";            
        }
        catch (Exception ex)
        {
            
            throw ex;
        }
    }
    #endregion
}
